home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / SourceCode / AdobeExamples / NX_Text / TextApp.m < prev    next >
Encoding:
Text File  |  1992-12-19  |  4.2 KB  |  184 lines

  1.  
  2. /*
  3.  * (a)  (C) 1990 by Adobe Systems Incorporated. All rights reserved.
  4.  *
  5.  * (b)  If this Sample Code is distributed as part of the Display PostScript
  6.  *    System Software Development Kit from Adobe Systems Incorporated,
  7.  *    then this copy is designated as Development Software and its use is
  8.  *    subject to the terms of the License Agreement attached to such Kit.
  9.  *
  10.  * (c)  If this Sample Code is distributed independently, then the following
  11.  *    terms apply:
  12.  *
  13.  * (d)  This file may be freely copied and redistributed as long as:
  14.  *    1) Parts (a), (d), (e) and (f) continue to be included in the file,
  15.  *    2) If the file has been modified in any way, a notice of such
  16.  *      modification is conspicuously indicated.
  17.  *
  18.  * (e)  PostScript, Display PostScript, and Adobe are registered trademarks of
  19.  *    Adobe Systems Incorporated.
  20.  * 
  21.  * (f) THE INFORMATION BELOW IS FURNISHED AS IS, IS SUBJECT TO
  22.  *    CHANGE WITHOUT NOTICE, AND SHOULD NOT BE CONSTRUED
  23.  *    AS A COMMITMENT BY ADOBE SYSTEMS INCORPORATED.
  24.  *    ADOBE SYSTEMS INCORPORATED ASSUMES NO RESPONSIBILITY
  25.  *    OR LIABILITY FOR ANY ERRORS OR INACCURACIES, MAKES NO
  26.  *    WARRANTY OF ANY KIND (EXPRESS, IMPLIED OR STATUTORY)
  27.  *    WITH RESPECT TO THIS INFORMATION, AND EXPRESSLY
  28.  *    DISCLAIMS ANY AND ALL WARRANTIES OF MERCHANTABILITY, 
  29.  *    FITNESS FOR PARTICULAR PURPOSES AND NONINFRINGEMENT
  30.  *    OF THIRD PARTY RIGHTS.
  31.  */
  32.  
  33. /*
  34.  *    TextApp.m
  35.  *
  36.  *    This subclass of the application class performs the global
  37.  *    setup needed for the TextApp application. The drawing
  38.  *    window is created.
  39.  *
  40.  *    Version:    2.0
  41.  *    Author:    Ken Fromm
  42.  *    History:
  43.  *            03-07-91        Added this comment.
  44.  */
  45.  
  46. #import "TextApp.h"
  47. #import "DocView.h"
  48. #import "DrawingView.h"
  49.  
  50. #import <appkit/ActionCell.h>
  51. #import <appkit/Panel.h>
  52. #import <appkit/ScrollView.h>
  53. #import <appkit/Window.h>
  54. #import <appkit/nextstd.h>
  55.  
  56. static NXRect            windowRect = {150, 193, 550, 600};
  57. static NXRect            paperRect = {0, 0, 612, 792};
  58.  
  59. @implementation TextApp
  60.  
  61. /*
  62. *    Allocate the memory for the user path description buffers. Create the
  63. *    window for drawing the image.
  64. */
  65. + new
  66. {
  67.     self = [super new];
  68.     [self  createWindow];
  69.  
  70.     return self;
  71. }
  72.  
  73. /*
  74. *    Create the drawing window and place a scrollview as the content view.
  75. *    A DrawingView instance is placed as the DocView of the ScrollView.
  76. */
  77. - createWindow
  78. {
  79.     id        docView, scrollView;
  80.  
  81.      NXPoint        viewPt;
  82.  
  83.     NXRect        tempRect, frameRect;
  84.  
  85.     windowId = [Window newContent:&windowRect
  86.             style:NX_TITLEDSTYLE
  87.             backing:NX_BUFFERED
  88.             buttonMask:NX_RESIZEBUTTONMASK
  89.             defer:NO];
  90.  
  91.     [Window  getContentRect:&tempRect  forFrameRect:&windowRect  style:NX_TITLEDSTYLE];
  92.     scrollView = [ScrollView newFrame:&tempRect];
  93.     [scrollView setBorderType:SCROLLVIEW_BORDER];
  94.     [scrollView  setVertScrollerRequired:YES];
  95.     [scrollView  setHorizScrollerRequired:YES];
  96.  
  97.     drawingviewId = [DrawingView  newFrame:&paperRect];
  98.     docView = [[[DocView new]  setClipping:NO] setScale:1.0];
  99.     [scrollView  setDocView:docView];
  100.     [[docView  superview]  setFlipped:NO];
  101.     [docView  addDrawView:drawingviewId];
  102.  
  103.     [[windowId setContentView:scrollView] free];
  104.  
  105.     [windowId setTitle:"PostScript Text Handling Application"];
  106.     [windowId makeFirstResponder:drawingviewId];
  107.     [windowId setDelegate:self];
  108.  
  109.     /* Center the drawing view in the window. */
  110.     [windowId disableDisplay];
  111.         [docView  placeDrawView];
  112.  
  113.         [docView  getFrame:&frameRect];
  114.         [[docView  superview]  getFrame:&tempRect];
  115.  
  116.         viewPt.x = (frameRect.size.width - tempRect.size.width)/2 ;
  117.         viewPt.y = (frameRect.size.height - tempRect.size.height)/2;
  118.         [docView  scrollPoint:&viewPt];        
  119.     [windowId reenableDisplay];
  120.     [windowId  display];
  121.  
  122.     [windowId  makeKeyAndOrderFront:self];
  123.  
  124.     return self;
  125. }
  126.  
  127. /* The window will free the its subviews. */
  128. - free
  129. {
  130.     [windowId  free];
  131.  
  132.     return [super free];
  133. }
  134.  
  135. - setFontPopup:anObject
  136. {
  137.     [[[anObject  target]  setTarget:NULL]  setAction:@selector(fontsize:)];
  138.  
  139.     return self;
  140. }
  141.  
  142. - rotationField
  143. {
  144.     return rotationField;
  145. }
  146.  
  147. - timingMatrix
  148. {
  149.     return timingMatrix;
  150. }
  151.  
  152. - statusMatrix
  153. {
  154.     return statusMatrix;
  155. }
  156.  
  157. - kernMatrix
  158. {
  159.     return kernMatrix;
  160. }
  161.  
  162. - widthMatrix
  163. {
  164.     return widthMatrix;
  165. }
  166.  
  167. - comparisonsMatrix
  168. {
  169.     return comparisonsMatrix;
  170. }
  171.  
  172. /*
  173.  * Resizes the doc view and repositions the drawing view inside the doc view.
  174.  */
  175. - windowDidResize:sender
  176. {
  177.     [[drawingviewId  superview]  placeDrawView];
  178.  
  179.     return self;
  180. }
  181.  
  182. @end
  183.  
  184.